package com.first.agent.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.first.agent.common.R;
import com.first.agent.pojo.User;
import com.first.agent.pojo.UserJ;
import com.first.agent.service.UserManagementService;
import com.first.agent.service.impl.UserManagementServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/system/userManagementFindUser")
public class UserManagementFindUserServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id = Integer.parseInt(req.getParameter("id"));
        UserManagementService userManagementService = new UserManagementServiceImpl();
        R<UserJ> r = userManagementService.findUser(id);
        //对页面进行数据响应
        resp.setContentType("application/json;charset=utf-8");
        PrintWriter pw=resp.getWriter();
        pw.write(JSONObject.toJSONString(r));
        pw.flush();
        pw.close();
    }
}
